<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">

            <h:form id="cepForm" acceptcharset="utf-8">
                <h1 class="title">Titulo e Documentos</h1>
                <p:growl id="messages" showDetail="true" autoUpdate="true"  /> 
                <div class="row">
                    <div class="twelve columns"> 
                        <fieldset>
                            <legend> <h4 style="margin:0 0 10px 0">Editando</h4></legend>
                            
                             <div style="float:right;">
                                
                                <p:button icon="ui-icon-pencil" 
                                          value="Editar" 
                                          href="editTitleDocument.xhtml?tdEdit=#{managerSearchTitleDocument.titleDocumentShow.id}"/>
                            </div>
                            <div class="clear"/>
                            <p:panel id="charterPanel" style="background: none; border: none;" 
                                     styleClass="container_24 clearfix ">


                                <p:outputLabel value="Número: " styleClass="grid_3"/>
                                <h:outputText styleClass="grid_8" value="#{managerSearchTitleDocument.titleDocumentShow.register}"/>

                                <p:outputLabel value="Tipo: " styleClass="grid_4"/>
                                <div class="grid_8">
                                    <h:outputText value="#{managerSearchTitleDocument.titleDocumentShow.typeTitleDocument}"/>
                                </div>
                                <div class="clear"/>
                                
                                <p:outputLabel value="Protocolo: " styleClass="grid_3"/>
                                <h:outputText styleClass="grid_8" value="#{managerSearchTitleDocument.titleDocumentShow.protocolo}"/>   

                                <p:outputLabel value="Livro Protocolo: " styleClass="grid_4"/>                      
                                <h:outputText styleClass="grid_8" value="#{managerSearchTitleDocument.titleDocumentShow.bookprot}"/>   

                                <div class="clear"/>

                                <p:outputLabel value="Data Protocolo: " styleClass="grid_3"/>
                                <h:outputText styleClass="grid_8" value="#{managerSearchTitleDocument.titleDocumentShow.datebp}">
                                    <f:convertDateTime pattern="dd/MM/yyyy"/>
                                </h:outputText>

                                <p:outputLabel value="Data Titulo: " styleClass="grid_4"/>
                                <h:outputText styleClass="grid_8" value="#{managerSearchTitleDocument.titleDocumentShow.datetdoc}">
                                    <f:convertDateTime pattern="dd/MM/yyyy"/>
                                </h:outputText>


                                <div class="clear"/>

                                <p:outputLabel value="Livro: " styleClass="grid_3" />
                                <h:outputText styleClass="grid_8" value="#{managerSearchTitleDocument.titleDocumentShow.book}"/>

                                <p:outputLabel value="Livro Compl: " styleClass="grid_4"/>
                                <h:outputText styleClass="grid_8" value="#{managerSearchTitleDocument.titleDocumentShow.bookComp}"/> 

                                <div class="clear"/>

                                <p:outputLabel value="Folha: " styleClass="grid_3" />
                                <h:outputText styleClass="grid_8" value="#{managerSearchTitleDocument.titleDocumentShow.leaf}"/> 

                                <p:outputLabel value="Folha Compl: " styleClass="grid_4"/>
                                <h:outputText styleClass="grid_8" value="#{managerSearchTitleDocument.titleDocumentShow.leafComp}"/> 


                                <div class="clear"/>
                                <p:outputLabel value="Objeto: " styleClass="grid_3"/>
                                <h:outputText styleClass="grid_20" value="#{managerSearchTitleDocument.titleDocumentShow.obj}"/> 

                                <div class="clear"/>
                                <p:outputLabel value="Observações: " styleClass="grid_3"/>
                                <h:outputText styleClass="grid_20" value="#{managerSearchTitleDocument.titleDocumentShow.obs}"/> 
                            </p:panel>

                        </fieldset>
                        <fieldset>
                            <legend> <h4 style="margin:0 0 10px 0">Partes</h4></legend>

                            <p:panel id="partsPanel" style="background: none; border: none;" styleClass="container_24 clearfix ">

                                <p:dataTable value="#{managerSearchTitleDocument.titleDocumentShow.parts}"
                                             emptyMessage="Nenhum registro encontrado"
                                             rowIndexVar="rowid"
                                             id="dataTableParts" var="partTable">
                                    <f:facet name="header">
                                        Partes
                                    </f:facet>
                                    <p:column headerText="Nome" width="550">
                                        #{partTable.people.name}
                                    </p:column>

                                    <p:column headerText="Documento">
                                        #{partTable.people.cpf}
                                        #{partTable.people.cnpj}
                                    </p:column>

                                    <p:column headerText="Qualidade">
                                        #{partTable.partQuality.description}
                                    </p:column>

                                </p:dataTable>

                            </p:panel>
                        </fieldset>
                        <fieldset>
                            <legend> <h4 style="margin:0 0 10px 0">Selos</h4></legend>

                            <p:panel id="stampPanel" 
                                     style="background: none; border: none;" styleClass="container_24 clearfix ">

                                <p:dataTable id="dataTableStamps"
                                             value="#{managerSearchTitleDocument.titleDocumentShow.stamp}"
                                             var="stampTable"
                                             emptyMessage="Nenhum registro encontrado" >
                                    <f:facet name="header">
                                        Selos
                                    </f:facet>
                                    <p:column headerText="Série">
                                        #{stampTable.serie}
                                    </p:column>
                                    <p:column headerText="Número">
                                        #{stampTable.number}
                                    </p:column>
                                    <p:column headerText="Tipo">
                                        #{stampTable.typeStamp.name}
                                    </p:column>

                                </p:dataTable>
                            </p:panel>
                        </fieldset>
                        <br/>

                        <fieldset>
                                <legend> <h4 style="margin:0 0 10px 0">Anexos</h4></legend>
                                <ui:repeat  value="#{managerSearchTitleDocument.titleDocumentShow.annex}" var="a">

                                    <h:outputLink  
                                        value="#{a.type ne 'application/pdf' ? 'viewImage':'show'}" title="#{a.description}"  target="_blank" >

                                        <div style="text-align: center; width: 20%;" class="grid_4">

                                            <p:graphicImage styleClass="image grid_3" rendered="#{a.type ne 'application/pdf'}"
                                                            style="margin-left:1%; width: 100px;"
                                                            url="show/?annex=#{a.id}" />

                                            <p:outputLabel  value="#{a.description.length() ge 10 ? a.description.substring(0, 10).concat('...') : 
                                                                     a.description.replace('.png','').replace(' ','_')}" 
                                                            style="margin-left:1%; width: 100px;" rendered="#{a.type ne 'application/pdf'}"/>

                                            <p:graphicImage styleClass="image grid_3" rendered="#{a.type eq 'application/pdf'}"
                                                            style="margin-left:1%; width: 100px;" 
                                                            url="assets/images/pdf.jpeg" />


                                            <p:outputLabel  value="#{a.description.length() ge 10 ? a.description.substring(0, 10).concat('...') : 
                                                                     a.description.replace('.pdf','').replace(' ','_')}" 
                                                            style="margin-left:1%; width: 100px;" rendered="#{a.type eq 'application/pdf'}"/>
                                        </div>
                                        <f:param name="annex" value="#{a.id}"/>
                                    </h:outputLink>

                                </ui:repeat>
                                <br/>
                            </fieldset>

                        <div class="buttonAction">
                            <p:button value="Voltar" href="searchTitleDocument.xhtml" icon="ui-icon-arrowreturnthick-1-w" />
                        </div >
                    </div>
                </div>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
